2020-2021 Sunseeker Telemetry and Lighting System
ldopwr_ex3_internalLDOEnabled.c
Go to the documentation of this file.
1 /* --COPYRIGHT--,BSD
2  * Copyright (c) 2017, Texas Instruments Incorporated
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  *
9  * * Redistributions of source code must retain the above copyright
10  * notice, this list of conditions and the following disclaimer.
11  *
12  * * Redistributions in binary form must reproduce the above copyright
13  * notice, this list of conditions and the following disclaimer in the
14  * documentation and/or other materials provided with the distribution.
15  *
16  * * Neither the name of Texas Instruments Incorporated nor the names of
17  * its contributors may be used to endorse or promote products derived
18  * from this software without specific prior written permission.
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
22  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
24  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
25  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
26  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
27  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
28  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
29  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
30  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  * --/COPYRIGHT--*/
32 //******************************************************************************
68 //******************************************************************************
69 
70 #include "driverlib.h"
71 
72 void main (void)
73 {
74  //Stop WDT
75  WDT_A_hold(WDT_A_BASE);
76 
77  //Set P1.0 to output direction
78  GPIO_setAsOutputPin(
79  GPIO_PORT_P1,
80  GPIO_PIN0
81  );
82 
83  //Detect if sufficient voltage at LDOI is present
84  if (LDOPWR_LDO_INPUT_VALID == LDOPWR_isLDOInputValid(
85  LDOPWR_BASE
86  ) ){
87  //Valid LDOI, LED on
89  GPIO_PORT_P1,
90  GPIO_PIN0
91  );
92  } else {
93  //Clear P1.0 LED off
95  GPIO_PORT_P1,
96  GPIO_PIN0
97  );
98  }
99 
100 
101  //Enable access to config registers
102  LDOPWR_unLockConfiguration(LDOPWR_BASE);
103 
104  //Clear all LDO-PWR IFGs before enabled IE bits
105  LDOPWR_clearInterrupt(LDOPWR_BASE,
106  LDOPWR_LDOI_VOLTAGE_GOING_OFF_INTERRUPT +
107  LDOPWR_LDOI_VOLTAGE_COMING_ON_INTERRUPT +
108  LDOPWR_LDO_OVERLOAD_INDICATION_INTERRUPT
109  );
110 
111  //Enable LDO-PWR interrupts
112  LDOPWR_enableInterrupt(LDOPWR_BASE,
113  LDOPWR_LDOI_VOLTAGE_GOING_OFF_INTERRUPT +
114  LDOPWR_LDOI_VOLTAGE_COMING_ON_INTERRUPT +
115  LDOPWR_LDO_OVERLOAD_INDICATION_INTERRUPT
116  );
117 
118 
119  //Disbale access to config registers
120  LDOPWR_lockConfiguration(LDOPWR_BASE);
121 
122  //Enter LPM3 w/ interrupts
123  __bis_SR_register(LPM3_bits + GIE);
124 
125  //For debugger
126  __no_operation();
127 }
128 
129 //******************************************************************************
130 //
131 //This is the LDO_PWR_VECTOR interrupt vector service routine.
132 //
133 //******************************************************************************
134 #if defined(__TI_COMPILER_VERSION__) || defined(__IAR_SYSTEMS_ICC__)
135 #pragma vector=LDO_PWR_VECTOR
136 __interrupt
137 #elif defined(__GNUC__)
138 __attribute__((interrupt(LDO_PWR_VECTOR)))
139 #endif
141 {
142  if (LDOPWR_getInterruptStatus(LDOPWR_BASE,
143  LDOPWR_LDOI_VOLTAGE_COMING_ON_INTERRUPT
144  )){
145  //Enable access to config registers
146  LDOPWR_unLockConfiguration(LDOPWR_BASE);
147 
148  //Software clear IFG
149  //Its possible that current peaks due to charging cap
150  //at LDOO might cause the LDOOVLIFG to trigger
151  LDOPWR_clearInterrupt(LDOPWR_BASE,
152  LDOPWR_LDO_OVERLOAD_INDICATION_INTERRUPT +
153  LDOPWR_LDOI_VOLTAGE_COMING_ON_INTERRUPT
154  );
155 
156  //Disbale access to config registers
157  LDOPWR_lockConfiguration(LDOPWR_BASE);
158 
159  //Valid LDOI, LED on
161  GPIO_PORT_P1,
162  GPIO_PIN0
163  );
164  } else if (LDOPWR_getInterruptStatus(LDOPWR_BASE,
165  LDOPWR_LDO_OVERLOAD_INDICATION_INTERRUPT
166  )){
167  //Enable access to config registers
168  LDOPWR_unLockConfiguration(LDOPWR_BASE);
169 
170  //Software clear IFG
171  LDOPWR_clearInterrupt(LDOPWR_BASE,
172  LDOPWR_LDO_OVERLOAD_INDICATION_INTERRUPT
173  );
174 
175 
176  //Disbale access to config registers
177  LDOPWR_lockConfiguration(LDOPWR_BASE);
178 
179  //Over load indication; take necessary steps in application firmware
180  while (1) ;
181  } else if (LDOPWR_getInterruptStatus(LDOPWR_BASE,
182  LDOPWR_LDOI_VOLTAGE_GOING_OFF_INTERRUPT
183  )){
184  //Enable access to config registers
185  LDOPWR_unLockConfiguration(LDOPWR_BASE);
186 
187 
188  //Software clear IFG
189  LDOPWR_clearInterrupt(LDOPWR_BASE,
190  LDOPWR_LDOI_VOLTAGE_GOING_OFF_INTERRUPT
191  );
192 
193  //Disbale access to config registers
194  LDOPWR_lockConfiguration(LDOPWR_BASE);
195 
196  //Voltage LDOI < launch voltage, LED off
198  GPIO_PORT_P1,
199  GPIO_PIN0
200  );
201  }
202 }
203 
__no_operation()
GPIO_setOutputHighOnPin(GPIO_PORT_LED1|GPIO_PORT_LED2, GPIO_PIN_LED1|GPIO_PIN_LED2)
GPIO_setOutputLowOnPin(GPIO_PORT_LED1|GPIO_PORT_LED2, GPIO_PIN_LED1|GPIO_PIN_LED2)
void main(void)
void LDOInterruptHandler(void)